import request from '@/utils/request'

/**
 * 获取所有角色
 */
export const roleList = () => {
  return request({
    url: '/role/list'
  })
}

/**
 * 获取指定角色的权限
 */
export const rolePermission = roleId => {
  return request({
    url: `/role/permission/${roleId}`
  })
}

/**
 * 为角色修改权限
 */
export const distributePermission = data => {
  return request({
    url: '/role/distribute-permission',
    method: 'POST',
    data
  })
}



export const list=params=>{
  return request({
    url: '/role/list',
    method:'post',
    params:params
  })
}
export const addRole=date=>{
  return request({
    url: '/role/add',
    method:'post',
    data:date
  })
}
export const RoleTreeList=params=>{
  return request({
    url: '/role/list',
    method:'post',
    params:params
  })
}
export const grantPermissions=data=>{
  return request({
    url: '/role/grantPermissions',
    headers:{
      'Content-Type': 'application/json'
    },
    method:'post',
    data:data
  })
}
export const getInfo=roleId=>{
  return request({
    url: `/role/`+roleId,
    method:'get',

  })
}

export const delRole=data=>{
  return request({
    url: `/role/delete`,
    method:'delete',
    data:data

  })
}
